package be.ipl.finito.daoimpl;

import java.util.ArrayList;
import java.util.List;

import javax.ejb.Stateless;

import be.ipl.finito.dao.JetonDao;
import be.ipl.finito.domaine.Jeton;

@SuppressWarnings("serial")
@Stateless
public class JetonDaoImpl extends DaoImpl<Integer, Jeton> implements JetonDao{

	@Override
	public List<Jeton> initialiser() {
		List<Jeton> jetons = new ArrayList<Jeton>();
		for (int i = 1; i <= 12; i++) {
			jetons.add(super.enregistrer(new Jeton(i)));
		}
		return jetons;
	}

	@Override
	public Jeton rechercher(String string) {
		int numero = Integer.parseInt(string);
		String query = "select j from Jeton j where j.numero = ?1";
		Jeton j = super.recherche(query, numero);
		return j;
	}
}